package ndk.caro.tools;

import android.graphics.PointF;

public class myLine {
	
	private final PointF v1;
	private final PointF v2;
	
	public myLine(PointF v1, PointF v2) {
		this.v1 = v1;
		this.v2 = v2;
	}
	
	public myLine(float x1, float y1, float x2, float y2 ) {
		this.v1 = new PointF(x1, y1);
		this.v2 = new PointF(x2,y2);
	}
	
	public int Compare2Line(myLine l) {
		return Compare2Line(l.v1, l.v2);
	}
	
	public int Compare2Line(PointF v1, PointF v2) {
		float space1 = this.spaceBetweenTwoVertex(this.v1, this.v2);
		float space2 = this.spaceBetweenTwoVertex(v1, v2);
		
		if(space1 < space2) return 1;
		else if(space1 == space2) return 0;
		
		return -1;
	}
	
	public float getSpace() {
		return this.spaceBetweenTwoVertex(this.v1, this.v2);
	}
	
	 public float spaceBetweenTwoVertex(PointF v1, PointF v2) {
		 return (float)
				 Math.sqrt(Math.pow(v1.x - v2.x, 2) + Math.pow(v1.y-v2.y, 2));
	 }
	 
	 public float spaceBetweenTwoVertex(float v1_x, float v1_y,float v2_x, float v2_y) {
		 return spaceBetweenTwoVertex(new PointF(v1_x,v1_y), new PointF( v2_x,v2_y));
	 }

}